<!-- 作品一览表格 -->
<script lang="ts">
export default {
  name: "xjyxListOfWorks",
};
</script>
<template>
  <div class="page-box h100 display-flex czbj">
    <p class="title-label mb10" v-if="pup!=2">
      作品一览
    </p>
    <div>
      <dxtable  :dataJson="dataJson" :portUrl="portUrl" :qx="qx" ref="databale"
        sonRouter="xjyxbjListWorks" :hidebj="hidebj" :headBtn='headBtn' :czFun="czFun"></dxtable>
    </div>
  </div>
  <n-modal v-model:show="showModal" preset="card" class="dsfsdrewrewe" >
    <template #header>
      <div>浏览二维码</div>
    </template>
    <div>
      <img :src="qcosertt" class="fsdfereertr">
    </div>
    <template #action>
      <div class="tr">
        <n-button @click="showModal=false"> 关闭 </n-button>
      </div>
    </template>
  </n-modal>
  <n-modal v-model:show="xzcxwerr" preset="card" class="Stock-diagnosis">
  <template #header>
  <div>评论管理</div>
  </template>
  <div>
  <plgl type="3" :plid='plid'></plgl>
  </div>
  <template #action>
  <div class="tr">
  <n-button @click="xzcxwerr=false"> 关闭 </n-button>
  </div>
  </template>
  </n-modal>
</template>
<script lang='ts' setup>
import { rowDark } from "naive-ui/es/legacy-grid/styles";
import dxtable from "../../../components/util/dxtable.vue";
import sort from "../../../components/util/sort.vue";
import dz from "../dz.vue";
import plgl from "../plgl.vue";
import { dxget, dxpost, qurl, hf } from "../../../util/index";
import { h, ref, reactive, onBeforeUpdate } from "vue";
import {NButton} from "naive-ui"
const props = defineProps({
  pup: { type: String },
  zfleix:{ type: String },
});
const xzcxwerr= ref(false)
const plid = ref()
const hidebj= ref(false)
const showModal = ref(false)
const qcosertt = ref()

let portUrl = "xjyx/zpyl";
let headBtn = ref([]);
const zdList = ref()
const databale = ref();
const videourl = ref()
const typeli = ref([])
const initeer = () => {
  databale.value.initDataExpose();
};
const emit = defineEmits(["callBack"]);
// 弹窗公用该列表
let dataJson = reactive([
  {
    title: "id",
    key: "id",
    width: 50,
  },

  {
    title: "作品名称",
    search: true, // 是否在搜索栏展示
    key: "title",
    width: 200,
  },
  {
    title: "地区",
    search: true, // 是否在搜索栏展示
    type: "select",
    options: [],
    key: "diqutext"
  },
  {
    title: "医院",
    search: true, // 是否在搜索栏展示
    key: "hospital"
  }, {
    title: "医生",
    search: true, // 是否在搜索栏展示
    key: "doctor"
  },
  {
    title: "产品分类",
    key: "cpyj",
    render(row) {
      return row.cpyj + '--' + row.cpej
    }
  }, {
    title: "二维码",
    key: "doctor",
    render(row) {
      

      // dxpost(portUrl,{id:row.id,qcCode:})
      return h('span', {
        class: "ls sz", onClick: async () => {
          qcosertt.value = row.qcCode
          if(qcosertt.value){
            showModal.value = true
            return
          }
          const { data }: any = await dxget("xjyx/public/index/updataImg", { id: row.id })
          await dxpost(portUrl, { id: row.id, qcCode: data }, "put")
          qcosertt.value = data
          showModal.value = true
        }
      }, "浏览二维码")
    }
  },
  {
    title: "点赞基数",
    key: "dianzan",
    width: 100,
    render(row) {
      return h(dz, {
        row,
        api:'xjyx/list/zpyl',
        keyName:"dianzan",
        onCallBack: () => {
          initeer();
        },
      })
      
    }
  }, {
    title: "收藏基数",
    key: "scjs",
    width: 100,
    render(row) {
      return h(dz, {
        row,
        api:'xjyx/list/zpyl',
        keyName:"scjs",
        onCallBack: () => {
          initeer();
        },
      })
      
    }
  },
  {
    title: "排序",
    width: 100,
    render(row) {
      row.databaseName = "zpyl";
      row.sjk = "xjyx"
      return h(sort, {
        row,
        onCallBack: () => {
          initeer();
        },
      });
    },
  },
  {
    title: "添加时间",
    key: "addTime",
    width: "140",
    type: "daterange",
  },
]);
let qx = ref({
  DeletePermissionID: "xjyxListOfWorksdel", //删除
  EditPermissionIdentifier: "xjyxListOfWorksbj", // 编辑
  NewPermissionIdentifier: "xjyxListOfWorksxz", // 新建
  ViewPermissionID: "xjyxListOfWorksck", // 查看
})
if(props.pup==2){
 dataJson = [

  {
    title: "作品名称",
    search: true, // 是否在搜索栏展示
    key: "title",
    width: 400,
  },
  {
    title: "医院",
    search: true, // 是否在搜索栏展示
    key: "hospital"
  }, {
    title: "医生",
    search: true, // 是否在搜索栏展示
    key: "doctor"
  },
];
hidebj.value = true

qx.value = {
  DeletePermissionID: "23456", //删除
  EditPermissionIdentifier: "", // 编辑
  NewPermissionIdentifier: "23456", // 新建
  ViewPermissionID: "", // 查看
}
headBtn.value = [
  {
    name: "确认添加",
    jy: true,
    type: "info",
    clickFun: async (calld) => {
      if(calld.length<=0){
       window.$message.error('请在列表中勾选数据')
        return
      }
      const {data} =  await dxpost('xjyx/api/addZxdf', { ids:calld.join(','), zfleix:props.zfleix})
     
      emit('callBack')
      },
  },
]
}

const getcasetype = async () => {
  const { data }: any = await dxget("dxgjAdmin/getzd", { name: 'xjdiqu' })

  dataJson[2].options = [
    {
      label: "全部",
      value: ""
    },
    ...data
  ]
  data.map(a => {
    a.value = a.label
  })
  typeli.value = data
  // ishjwoer.value = true
}
getcasetype()


const czFun = {
    fun: (row, loading) => {
        return [
            h(
                NButton,
                {
                    type: "info",
                    quaternary: true,
                    onClick: async (e) => {
                      xzcxwerr.value = true
                      plid.value = row.id
                    },
                },
                "评论管理"
            )

        ];
    },
};

</script>
<style scoped>
.fsdfereertr{
  width: 100%;
  height: 360px;
}
</style>
  
  
  